texttag: add gtk_text_tag_changed()
authorSébastien Wilmet <sebastien.wilmet@uclouvain.be>
Thu, 24 Sep 2015 08:59:32 +0000 (10:59 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 4 Oct 2015 02:24:17 +0000 (22:24 -0400)
The function is useful for a GtkTextTag subclass that adds new
properties.

https://bugzilla.gnome.org/show_bug.cgi?id=755416

docs/reference/gtk/gtk3-sections.txt
gtk/gtktexttag.c
gtk/gtktexttag.h
gtk/gtktexttagtable.c

index 945726e2bdf4189e853aa62a71adcc4012b75af7..e9c8ddc333d3e8d6f3fc1fc992e12fad38f428cd 100644 (file)
@@ -3809,6 +3809,7 @@ gtk_text_tag_new
 gtk_text_tag_get_priority
 gtk_text_tag_set_priority
 gtk_text_tag_event
+gtk_text_tag_changed
 GtkTextAttributes
 GtkTextAppearance
 gtk_text_attributes_new
index a05a6bbfe8e9979ddceac0492c34b205b8a71fa5..13d234f96d1341ec4c2ad10dad95a31116fa66ec 100644 (file)
@@ -1822,20 +1822,12 @@ gtk_text_tag_set_property (GObject      *object,
       break;
     }
 
-  /* FIXME I would like to do this after all set_property in a single
-   * g_object_set () have been called. But an idle function won't
-   * work; we need to emit when the tag is changed, not when we get
-   * around to the event loop. So blah, we eat some inefficiency.
+  /* The signal is emitted for each set_property(). A possible optimization is
+   * to send the signal only once when several properties are set at the same
+   * time with e.g. g_object_set(). The signal could be emitted when the notify
+   * signal is thawed.
    */
-
-  /* This is also somewhat weird since we emit another object's
-   * signal here, but the two objects are already tightly bound.
-   */
-
-  if (priv->table)
-    g_signal_emit_by_name (priv->table,
-                           "tag_changed",
-                           text_tag, size_changed);
+  gtk_text_tag_changed (text_tag, size_changed);
 }
 
 static void
@@ -2294,6 +2286,40 @@ gtk_text_tag_event (GtkTextTag        *tag,
   return retval;
 }
 
+/**
+ * gtk_text_tag_changed:
+ * @tag: a #GtkTextTag.
+ * @size_changed: whether the change affects the #GtkTextView layout.
+ *
+ * Emits the #GtkTextTagTable::tag-changed signal on the #GtkTextTagTable where
+ * the tag is included.
+ *
+ * The signal is already emitted when setting a #GtkTextTag property. This
+ * function is useful for a #GtkTextTag subclass.
+ *
+ * Since: 3.20
+ */
+void
+gtk_text_tag_changed (GtkTextTag *tag,
+                      gboolean    size_changed)
+{
+  GtkTextTagPrivate *priv;
+
+  g_return_if_fail (GTK_IS_TEXT_TAG (tag));
+
+  priv = tag->priv;
+
+  /* This is somewhat weird since we emit another object's signal here, but the
+   * two objects are already tightly bound. If a GtkTextTag::changed signal is
+   * added, this would increase significantly the number of signal connections.
+   */
+  if (priv->table != NULL)
+    g_signal_emit_by_name (priv->table,
+                           "tag-changed",
+                           tag,
+                           size_changed);
+}
+
 static int
 tag_sort_func (gconstpointer first, gconstpointer second)
 {
index 1dae6024d2d75537333f03c208f73764d8ca2169..3e4ed33cc0595f210fbba45226cebda8345f35fa 100644 (file)
@@ -112,7 +112,9 @@ gboolean     gtk_text_tag_event        (GtkTextTag        *tag,
                                         GObject           *event_object,
                                         GdkEvent          *event,
                                         const GtkTextIter *iter);
-
+GDK_AVAILABLE_IN_3_20
+void         gtk_text_tag_changed      (GtkTextTag        *tag,
+                                        gboolean           size_changed);
 
 G_END_DECLS
 
index e44fb0ada0be0bf907edd290849f58ee2338a7d8..777cf310bd9f1f306ee8a633637696ba6f26b644 100644 (file)
@@ -103,7 +103,7 @@ gtk_text_tag_table_class_init (GtkTextTagTableClass *klass)
    * GtkTextTagTable::tag-changed:
    * @texttagtable: the object which received the signal.
    * @tag: the changed tag.
-   * @size_changed: whether the size has been changed.
+   * @size_changed: whether the change affects the #GtkTextView layout.
    */
   signals[TAG_CHANGED] =
     g_signal_new (I_("tag-changed"),